package com.aibaixun.system.service.impl;

import com.aibaixun.common.core.domain.R;
import com.aibaixun.common.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.aibaixun.system.domain.PlatformConfig;
import com.aibaixun.system.service.PlatformConfigService;
import com.aibaixun.system.mapper.PlatformConfigMapper;
import org.springframework.stereotype.Service;

/**
* @author zhangyh
* @description 针对表【platform_config(平台配置文件信息)】的数据库操作Service实现
* @createDate 2023-09-12 14:49:37
*/
@Service
public class PlatformConfigServiceImpl extends ServiceImpl<PlatformConfigMapper, PlatformConfig>
    implements PlatformConfigService{

    @Override
    public R<PlatformConfig> getDetail(Integer configId) {
        PlatformConfig config = this.baseMapper.selectById(configId);
        if(config == null){
            return R.fail("配置文件信息不存在");
        }
        return R.ok(config);
    }

    @Override
    public R update(PlatformConfig dto) {
        if(dto.getConfigId() == null){
            return R.fail("配置文件信息不存在");
        }
        PlatformConfig config = this.baseMapper.selectById(dto.getConfigId());
        if(config == null){
            return R.fail("配置文件信息不存在");
        }
        BeanCopyUtils.copy(dto,config);
        this.baseMapper.updateById(config);
        return R.ok();
    }
}




